package backend.rss.items;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;

public class AuthorItem implements Item
{
	private String id;
	private String name;
	private String email;
	private String image;
	private Set<ThemeItem> themes;
	
	public AuthorItem(String id, String name, String image)
	{
		this.id 	= id;
		this.name 	= name;
		this.image	= image;
		
		themes	= new HashSet<ThemeItem>();
	}
	
	public AuthorItem(String id, String name)
	{
		this.id = id;
		this.name = name;
		themes = new HashSet<ThemeItem>();
	}
	
	
	public void addThemeItem(ThemeItem theme)
	{
		themes.add(theme);
	}

	/**
	 * @return the id
	 */
	public String getId()
	{
		return id;
	}

	/**
	 * @return the image
	 */
	public String getImage()
	{
		return image;
	}
	
	public URL getImageURL()
	{
		try
		{
			if (image == null || image.equals("")) return null;
			URL url = new URL(image);
			return url;
		}
		catch (MalformedURLException e)
		{
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * @return the name
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * @return the email
	 */
	public String getEmail()
	{
		return email;
	}

	/**
	 * @return the themeIds
	 */
	public Set<ThemeItem> getThemeItems()
	{
		return themes;
	}
	
	
}
